home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 015a / bbb_v21.zip / BET.DOC < prev    next >
Text File  |  1991-11-25  |  7KB  |  255 lines

  1.  
  2.                           -- BET v1.0 --
  3.                      Brent's Environment Tools
  4.                        (c) 1991 Brent Ashley
  5.  
  6. BET is a collection of tools to allow you to manipulate the DOS 
  7. environment variables as strings and long integers.  BET also 
  8. provides system information functions which assign their results 
  9. to either environment variables or DOS ERRORLEVELs (or both) to 
  10. assist you in building powerful batches, with emphasis on install 
  11. batches.  BET was written as a companion program to Brent's Batch 
  12. Beautifier (BBB), and is distributed with it.
  13.  
  14. Full source is now included for those who are interested.  
  15. Microsoft QuickBASIC v 4.0 or later and Crescent Software's
  16. PDQ version 2.16 or later are required to recompile the source.
  17.  
  18. Repeated calls to BET load it from disk each time, so you may want 
  19. to ensure you use a disk caching program or copy BET and BBB to a 
  20. RAM disk for faster access.
  21.  
  22. BET has two syntax forms, as shown below, from BET's own help 
  23. screen. The /D switch causes the environment variables and 
  24. ERRORLEVELs returned by the functions to be displayed, making for 
  25. easy debugging.
  26.  
  27. Syntax:  BET [/D] ResultVar Action [Value1 [Value2...]] 
  28.     or:  BET [/D] IS Value1 LT/GT/LE/GE/EQ/NE Value2
  29.                           (returns ERRORLEVEL 255=True 0=False)
  30.  
  31. We'll start with the second form, which is for numerical 
  32. comparisons.
  33.  
  34. The IS keyword allows you to make comparisons between numerical 
  35. values using the following operators:
  36.  
  37. LT - less than
  38. GT - greater than
  39. LE - less than or equal to
  40. GE - greater than or equal to
  41. EQ - equal to
  42. NE - not equal to
  43.  
  44. BET returns a DOS ERRORLEVEL of 0 for FALSE and 255 for TRUE
  45.  
  46. Example: Check if environment variable Count is less than 20 and
  47.          transfer control to :Top if so.
  48.  
  49. BET IS %Count% LT 20
  50. IF ErrorLevel 255 GOTO Top
  51.  
  52. The other form of the BET command is the Action form, which allows 
  53. you many choices.  Only one action (and its parameters) is allowed 
  54. per line, however, since enviroment variables and/or ERRORLEVELs 
  55. need to be set for each action.
  56.  
  57. Syntax:  BET [/D] ResultVar Action [Value1 [Value2...]] 
  58.  
  59. ResultVar is the name of the environment variable to which you 
  60. want the result of the action assigned, and Action is one of the
  61. choices listed below.
  62.  
  63. If a variable named DUMMY is used for ResultVar, no environment 
  64. variable is created or changed.  ResultVar cannot be called "IS" 
  65. due to the IS comparison keyword.
  66.  
  67. Math actions:
  68. -------------
  69.  
  70. (&H and &O prefixes can be used for Hex and Octal numbers
  71.  eg: &HFF is the same as 255.)
  72.  
  73. HEX Value1
  74. - assigns the hexadecimal value of Value1 to ResultVar
  75.   Example: BET ThreeK HEX 3072
  76.   Gives: ThreeK=C00
  77.  
  78. ADD/SUB/MUL/DIV/MOD Value1 Value2
  79. - performs mathematical function on two integer values.
  80. - read as though function symbol is between values:
  81.   Example: BET Length DIV %Area% %Width%
  82.   Gives  : Length = Area / Width  
  83.   Example: BET Test MOD 123 100
  84.   Gives  : 123 MOD 100
  85.            = 23
  86.  
  87. String actions:
  88. ---------------
  89.  
  90. TargetVar is the variable upon which to perform the action.
  91. TargetVar and ResultVar can be the same variable.
  92.  
  93. LEFT/RIGHT TargetVar Characters
  94. - assigns a number of characters from left or right of TargetVar to
  95.   ResultVar
  96.  
  97. MID TargetVar Startpos Characters
  98. - assigns a number of characters from middle of TargetVar to 
  99.   ResultVar
  100.   Example: SET BracketedLetter=(A)
  101.            BET Letter MID %BracketedLetter% 2 1
  102.   Gives:   BracketedLetter=(A)
  103.            Letter=A       
  104.  
  105. LEN TargetVar
  106. - returns length of TargetVar as integer in ResultVar
  107.   and as DOS ERRORLEVEL
  108.  
  109. UPPER/LOWER TargetVar
  110. - Assigns TargetVar to ResultVar and forces all upper- or lower-case
  111.   on ResultVar
  112.  
  113. LTRIM/RTRIM TargetVar
  114. - trims spaces from left or right of TargetVar and assigns result 
  115.   to ResultVar
  116.  
  117. INSTR TargetVar Text
  118. - returns position of Text in TargetVar as integer in ResultVar
  119.   and as DOS ERRORLEVEL
  120. - use tilde ~ character in Text in place of spaces
  121.  
  122. APPEND Text
  123. - appends Text to end of ResultVar
  124.   (this is mostly useful at the command line, to add a directory 
  125.    to your PATH)
  126.  
  127. System info actions:
  128. --------------------
  129.  
  130. CPU
  131. - returns type of CPU installed (or equivalent eg. NEC V20 = 86)
  132.   ResultVar : 86, 286, or 386
  133.   ERRORLEVEL:  1,   2, or   3
  134.  
  135. VIDEO
  136. - Returns type of video adapter installed as per chart:
  137.  
  138.   ResultVar    ErrorLevel
  139.   -----------------------
  140.   Monochrome            1
  141.   Hercules              2
  142.   CGA                   3
  143.   EGA                   4
  144.   VGA                   5
  145.   MCGA                  6
  146.   8514/A                7
  147.  
  148. COLOR
  149. - returns whether color monitor is being used
  150.   ResultVar : YES, NO
  151.   ERRORLEVEL: 255,  0
  152.  
  153. MACHINEID
  154. - returns Machine Identification byte as hex number in ReturnVar
  155.  
  156. NPX
  157. - returns whether numeric processor extension (coprocessor) is  
  158.   installed.
  159.   ResultVar : YES, NO
  160.   ERRORLEVEL: 255,  0
  161.  
  162. MOUSE
  163. - returns whether mouse driver is installed
  164.   ResultVar : YES, NO
  165.   ERRORLEVEL: 255,  0
  166.  
  167. SERIAL/PARALLEL
  168. - returns number of serial or parallel ports installed in ResultVar
  169.   and as DOS ERRORLEVEL
  170.  
  171. TIME
  172. - assigns formatted time (eg 12:00am) to ResultVar
  173.  
  174. HOUR/MINUTE
  175. - returns hour (0-23) or minute (0-59) in ResultVar
  176.   and as DOS ERRORLEVEL
  177.  
  178. DATE
  179. - Returns date in mm/dd/yy format in ResultVar
  180.  
  181. WEEKDAY
  182. - Returns text (eg Monday) in ResultVar
  183.   and number (0=Sunday to 6=Saturday) as DOS ERRORLEVEL
  184.  
  185. DAY
  186. - returns day of month in ResultVar
  187.   and as DOS ERRORLEVEL
  188.  
  189. MONTH
  190. - returns text (eg January) in ResultVar
  191.   and number (1-12) as DOS ERRORLEVEL
  192.  
  193. YEAR
  194. - returns 4-digit year in ResultVar
  195.   and 2-digit year as DOS ERRORLEVEL
  196.  
  197. DOSVER
  198. - returns DOS version in format X.XX in ResultVar
  199.   and in format XX (eg 33 or 50) as DOS ERRORLEVEL
  200.  
  201. MODE
  202. - returns current video mode in ResultVar and as DOS ERRORLEVEL
  203.  
  204. LINES
  205. - returns current number of screen lines in ResultVar
  206.   and as DOS ERRORLEVEL
  207.  
  208. CURDRIVE
  209. - returns currently logged drive letter in ResultVar
  210.   and number (A=1 to Z=26) as DOS ERRORLEVEL
  211.  
  212. CURDIR
  213. - returns currently logged path (eg \DOS) in ResultVar
  214.  
  215. VALIDDRVS
  216. - returns string of valid drives (eg ABCNY) in ResultVar
  217.  
  218. MEM
  219. - returns amount of installed conventional memory in ResultVar
  220.  
  221. EXT 
  222. - returns amount of available extended memory in ResultVar
  223.  
  224. VOL DriveLetter
  225. - returns volume label of specified drive in ResultVar
  226.  
  227. TOGGLE CAP/NUM/INS/SCR [ON/OFF]
  228. - without ON or OFF reports status of lock keys
  229.   ResultVar : YES, NO
  230.   ERRORLEVEL: 255,  0
  231.   Example: BET CapOn TOGGLE CAP
  232. - ON and OFF set and clear lock status.  Older XT keyboards may not 
  233.   update their LEDs properly after such a change.
  234.  
  235.  
  236.                       -- Revision History --
  237.  
  238. 1.0 - first release 25 August 1991
  239.     - released with source 25 November 1991
  240.  
  241.                             -- Note --
  242.  
  243. BET and BBB are distributed as Freeware.  This means that while anyone can 
  244. use them at no cost in a personal, business, or government environment, I
  245. retain the copyright.  
  246.  
  247. Both programs were written in Microsoft QuickBASIC and linked with 
  248. Crescent Software's PDQ link library.  
  249.  
  250. Brent Ashley
  251. 8 Darnock Court
  252. Brampton, Ontario
  253. L6Z 2X3
  254. CANADA
  255.